/*
 * @Author: szx
 * @Date: 2021-11-10 17:24:47
 * @LastEditTime: 2021-11-10 18:25:01
 * @Description:
 * @FilePath: \leetcode\1-99\82\82.cpp
 */
#include <iostream>
using namespace std;
struct ListNode {
    int val;
    ListNode* next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode* next) : val(x), next(next) {}
};

class Solution {
   public:
    ListNode* deleteDuplicates(ListNode* head) {
        ListNode* prev = new ListNode(-1, head);
        ListNode* node = prev;

        while (head) {
            if (head->next && head->next->val == head->val) {
                while (head->next && head->next->val == head->val) {
                    head = head->next;
                }
                head = head->next;
                node->next = head;
                continue;
            }
            node = head;
            head = head->next;
        }
        return prev->next;
    }
};
int main() { return 0; }